package com.sky.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sky.entity.AddressBook;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AddressBookMapper extends BaseMapper<AddressBook> {
    void AddAddress(AddressBook addressBook);

    @Select("select * from address_book where user_id=#{userId}")
    List<AddressBook> GetAddressBookList(Long userId);

    @Select("select * from address_book where is_default=1 and user_id=#{userId}")
    AddressBook GetAddressBookDefault(Long userId);

    void UpdateAddressBook(AddressBook addressBook);

    @Delete("delete from address_book where id = #{id}")
    void deleteAddressBook(Integer id);

    @Select("select * from address_book where id=#{id}")
    AddressBook getAddressBookById(Integer id);

    @Update("update address_book set is_default = 1 where id=#{id}")
    void setAddressBookDefault(Integer id);
}
